
//
//  PublicGetUserInfoApi.m
//  3DPrint
//
//  Created by Fidetro on 2017/1/10.
//  Copyright © 2017年 Fidetro. All rights reserved.
//

#import "PublicGetUserInfoApi.h"

@implementation PublicGetUserInfoApi{
    NSDictionary *_dic;
}

-(id)initWithDic:(NSDictionary *)dic{
    if (self = [super init]) {
        _dic = dic;
    }
    return self;
}

- (NSString *)requestUrl {
    return @"/new/user/get_user_info";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (id)requestArgument {
    NSMutableDictionary *dic=[NSMutableDictionary getPubdic];

    NSString *sign=[NSString getSign:dic];
    [dic setObject:sign forKey:@"sign"];
    return dic;
}

- (void)analyseResponseObject {
    
    NSDictionary *dic = [self responseJSONObject];
    if([dic[@"errcode"] intValue] == 0) {
        NSDictionary * data = dic[@"data"];
        NSLog(@"[获取到用户信息data = %@]",data);
        SAVE_OBJECT(data[@"image"], IMAGE);
        SAVE_OBJECT(data[@"nickname"], NICKNAME);
        SAVE_OBJECT(data[@"username"], USERNAME);
        //        DTCSAVE_OBJECT(data[@"sex"], SEX);//1  2女
        //        DTCSAVE_OBJECT(data[@"birth"], BIRTH);//yyyy-mm
        //        DTCSAVE_OBJECT(data[@"height"], HEIGHT);
        //        DTCSAVE_OBJECT(data[@"weight"], WEIGHT);
        SAVE_OBJECT(data, INFODIC);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"UserInfoUpdate" object:nil];
        
    } else {
        
    }
    
}

@end
